C++ Recipes by Sutherland Bruce
Author:Sutherland, Bruce
Language: eng
Format: epub
ISBN: 978-1-4842-0158-9
Publisher: Apress
Published: 2015-05-15T04:00:00+00:00
int GetNumber() const
{
return m_Number;
}
};
using UniqueMyClass = unique_ptr< MyClass >;
void CreateUniqueObject()
{
UniqueMyClass uniqueMyClass{ make_unique<MyClass>(10) };
}
int main(int argc, char* argv[])
{
cout << "Begin Main!" << endl;
CreateUniqueObject();
cout << "Back in Main!" << endl;
return 0;
}
The unique_ptr in Listing 10-10 is created inside a function to demonstrate that the instance of the dynamically created object is destroyed when the unique_ptr goes out of scope. You can see this reflected in the output in Figure 10-9.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(20724)
Hello! Python by Anthony Briggs(20012)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(18332)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(17689)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(17496)
Kotlin in Action by Dmitry Jemerov(17308)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(16319)
Grails in Action by Glen Smith Peter Ledbrook(15467)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(13331)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10417)
Windows APT Warfare by Sheng-Hao Ma(7834)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(7549)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(7452)
Solidity Programming Essentials by Ritesh Modi(4568)
Functional Programming in JavaScript by Mantyla Dan(4445)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4433)
WordPress Plugin Development Cookbook by Yannick Lefebvre(4389)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(4270)
The Ultimate iOS Interview Playbook by Avi Tsadok(4252)